package com.fourth.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fourth.dao.BrandDao;
import com.fourth.service.BrandService;
import com.fourth.vo.BrandVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljx.entity.Brand;
import com.ljx.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiaoZhu
 * @version 1.0
 * @date 2023/2/27 22:45
 */
@Service
public class BrandServiceImpl extends ServiceImpl<BrandDao, Brand> implements BrandService {

    @Autowired
    private BrandDao brandDao;

    @Override
    public Result selectAll(Integer currentPage, Integer pageSize, BrandVo brandVo) {

        PageHelper.startPage(currentPage,pageSize);
        if (brandVo.getBrandid()!=null || brandVo.getSortid() !=null || brandVo.getStatus() != null){
            List<Brand> list1 =brandDao.selectAll1(brandVo);
            PageInfo<Brand> brandPageInfo = new PageInfo<>(list1);
            return new Result<>(200,"查询成功",brandPageInfo);
        }

        List<Brand> list = brandDao.selectAll();
        PageInfo<Brand> info = new PageInfo<>(list);
        return new Result(200,"查询成功",info);

    }
}
